package cn.itsource.org;

import cn.itsource.App;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import javax.mail.internet.MimeMessage;
import java.io.File;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class)
public class Mytest {
    @Autowired
    private JavaMailSender javaMailSender;
    @Test
    public void test1() throws Exception {
        //创建邮件对象
        MimeMessage message = javaMailSender.createMimeMessage();
        //发送邮件复杂工具类
        MimeMessageHelper helper = new MimeMessageHelper(message, true, "utf-8");
        //System.out.println(helper);
        //发件人
        helper.setFrom("1014792931@qq.com");
        helper.setTo("2914839112@qq.com");
        //标题
        helper.setSubject("加v看美羊羊洗澡");
        //内容
        helper.setText("<div>\n" +
                "      <span>审核通过，请点击下方链接激活账号</span>\n" +
                "      <a href='http://192.168.180.142:8081/fastDfs/upload'>激活账号</a>\n" +
                "    </div>",true);
        helper.addAttachment("看看.rar",new File("C:\\Users\\hp\\Desktop\\123\\3458274885714944.zip"));

        javaMailSender.send(message);
    }
}
